<?php
$this->breadcrumbs=array(
	'Bt_Batterys'=>array('admin'),
	
);
?>

<div id="page-header">
	<h1><?php echo "查看".$this->moduleName; ?></h1>
</div>

<?php echo CHtml::submitButton('图形显示', array(
     'submit'=>Yii::app()->controller->createUrl('Btbatterys/charts'
     		.'&'."redirect=1" 
	     	.'&'."select_unit=".Yii::app()->controller->select_unit
     		.'&'."select_maker=".Yii::app()->controller->select_maker
     		.'&'."select_size=".Yii::app()->controller->select_size
     		.'&'."select_timer=".Yii::app()->controller->select_timer
  
     		 ),
		'class'=>'button blue'
     // or simply
     //'submit'=>'mycontroller/myaction'
)); ?>
<?php echo CHtml::submitButton('数据导出', array(
     'submit'=>Yii::app()->controller->createUrl('Btbatterys/importdata'
			.'&'."redirect=1" 
     	    .'&'."select_unit=".Yii::app()->controller->select_unit
     		.'&'."select_maker=".Yii::app()->controller->select_maker
     		.'&'."select_size=".Yii::app()->controller->select_size
     		.'&'."select_timer=".Yii::app()->controller->select_timer
 
		),
		'class'=>'button blue'
     // or simply
     //'submit'=>'mycontroller/myaction'
)); ?>
<section class="grid_9 ui-tabs ui-widget ui-widget-content ui-corner-all" id="dashtabs">
<div class="box-header">
  <?php echo $this->moduleName."列表"; ?></div>
<?php 
function getTime($data, $type, $stime){
	switch($type){
		case 'start':
			//echo $data["green"];			
			
			break;
		case 'end':
			return CHtml::link($data["green"], array("btBatterys/details","status"=>1,"end_time"=>$etime));
			break;
	}	
}

function getColumnSTime($data){
return array(
	'type'=>'raw',
	'class'=>'CDataColumn',
	'header'=>'站点名称',//显示表名称	
	'name' => 'start_time',		
	//'urlExpression'=>'Yii::app()->createUrl("btBatterys/details",array("status"=>1, "start_time"=>'.$stime.'))',//显示URL
	'value' => 'CHtml::link($data["green"], array("btBatterys/details","status"=>1,"start_time"=>$stime))',
);
}

$this->widget('zii.widgets.grid.CGridView', array(
    'dataProvider'=>$dataProvider,	
    'htmlOptions'=>array(
    	'class'=>'cgridview'
    ),
		
	'columns'=>array(
		array(
			'name' => '流水号',
			'value' => '$data["id"]',
		),
		 
		array(
			'visible'=> Yii::app()->controller->unit_visible_tag == true ? true : false   ,
			'header' => '单位名称',
			'name' => 'unitSearch',
			'value' => Yii::app()->controller->level ==1 ? '$data["province_name"]' :
					(Yii::app()->controller->level == 2 ? '$data["province_name"].$data["city_name"]':
					(Yii::app()->controller->level == 3 ? '$data["province_name"].$data["city_name"].$data["county_name"]' :
					'$data["province_name"].$data["city_name"].$data["county_name"].$data["base_name"]')),
		),
			
		array(
			'visible'=> Yii::app()->controller->maker_visible_tag  == 1 ? true : false   ,
			'header' => '制造商',
			'name' => 'manname',
			'value' => '$data["manname"]',
		),
		array(
				'visible'=> Yii::app()->controller->guige_visible_tag  ==1 ? true:false   ,
						'header' => '电池规格',
						'name' => 'btype',
						'value' => '$data["BATTERYTYPE_V"]',
		),
			array(
					'visible'=> Yii::app()->controller->time_visible_tag  ==1 ? true:false   ,
					'header' => '安装年代',
					'name' => 'setup_d',
					'value' => '$data["SETUP_D"]',
			),
		array(
			'name' => '总计',
			'value' => '$data["green_n"] + $data["yellow_n"] + $data["red_n"] ',
		), 
		array(
			'type'=>'html',
			'header'=>'绿色',//显示表名称		
			//'urlExpression'=>'Yii::app()->createUrl("btBatterys/details",array("status"=>1, "start_time"=>Yii::app()->controller->start_time))',//显示URL
			'value' => 'CHtml::link($data["green_n"], array("btBatterys/details","status"=>0, 
				"redirect"=>1, 
				"select_unit"=>Yii::app()->controller->select_unit,
				"select_maker"=>Yii::app()->controller->select_maker,
				"select_size"=>Yii::app()->controller->select_size,
				"select_timer"=>Yii::app()->controller->select_timer,
				"option_id"=>Yii::app()->controller->group_option == 1 ? $data["man_id"]:   
					(Yii::app()->controller->group_option == 2 ? $data["type_id"]:
					(Yii::app()->controller->group_option == 3 ? $data["SETUP_D"]:
					(Yii::app()->controller->group_option == 10 ? $data["province_id"] :
					(Yii::app()->controller->group_option == 11 ? $data["city_id"] :
					(Yii::app()->controller->group_option == 12 ? $data["county_id"] : 
					(Yii::app()->controller->group_option == 13 ? $data["base_id"] : "none"
					 )))))),
				))',
		),
			array(
					'class'=>'CLinkColumn',
					'header'=>'黄色',//显示表名称
					'labelExpression'=>'$data["yellow_n"]',
					'urlExpression'=>'Yii::app()->createUrl("btBatterys/details",array("status"=>1,  
					"redirect"=>1, 
					"select_unit"=>Yii::app()->controller->select_unit,
					"select_maker"=>Yii::app()->controller->select_maker,
					"select_size"=>Yii::app()->controller->select_size,
					"select_timer"=>Yii::app()->controller->select_timer,
				"option_id"=>Yii::app()->controller->group_option == 1 ? $data["man_id"]:   
					(Yii::app()->controller->group_option == 2 ? $data["type_id"]:
					(Yii::app()->controller->group_option == 3 ? $data["SETUP_D"]:
					(Yii::app()->controller->group_option == 10 ? $data["province_id"] :
					(Yii::app()->controller->group_option == 11 ? $data["city_id"] :
					(Yii::app()->controller->group_option == 12 ? $data["county_id"] : 
					(Yii::app()->controller->group_option == 13 ? $data["base_id"] : "none"
					 )))))),
					))',//显示URL
			),
			array(
					'class'=>'CLinkColumn',
					'header'=>'红色',//显示表名称
					'labelExpression'=>'$data["red_n"]',
					'urlExpression'=>'Yii::app()->createUrl("btBatterys/details",array("status"=>2, 
					"redirect"=>1, 
					"select_unit"=>Yii::app()->controller->select_unit,
					"select_maker"=>Yii::app()->controller->select_maker,
					"select_size"=>Yii::app()->controller->select_size,
					"select_timer"=>Yii::app()->controller->select_timer,
				"option_id"=>Yii::app()->controller->group_option == 1 ? $data["man_id"]:   
					(Yii::app()->controller->group_option == 2 ? $data["type_id"]:
					(Yii::app()->controller->group_option == 3 ? $data["SETUP_D"]:
					(Yii::app()->controller->group_option == 10 ? $data["province_id"] :
					(Yii::app()->controller->group_option == 11 ? $data["city_id"] :
					(Yii::app()->controller->group_option == 12 ? $data["county_id"] : 
					(Yii::app()->controller->group_option == 13 ? $data["base_id"] : "none"
					 )))))),
					))',//显示URL
			),

	 ),
	
    'template'=>'{items}{summary}{pager}',
    'cssFile' => Yii::app()->request->baseUrl.'/css/widgets/cgridview.css'
)); ?>
</section>



<section class="grid_9 ui-tabs ui-widget ui-widget-content ui-corner-all" id="dashtabs">
<div class="box-header">
  <?php echo  "电池组列表"; ?></div>
<?php 
$this->widget('zii.widgets.grid.CGridView', array(
    'dataProvider'=>$dataProvider_details,
    'htmlOptions'=>array(
    	'class'=>'cgridview'
    ),
'pager'=>array(              //通过pager设置样式   默认为CLinkPager
		'prevPageLabel'=>'上一页',
		'firstPageLabel'=>'首页',  //first,last 在默认样式中为{display:none}及不显示，通过样式{display:inline}即可
		'nextPageLabel'=>'下一页',
		'lastPageLabel'=>'末页',

),
'columns'=>array(
array(                       //具体设置每列的header
		'name'=>'流水号',
		'value'=>'$data["id"]',
),
array(   
		                   //具体设置每列的header
		'header'=>'站点名称',
		//'name'=>'unit_search',
		'value'=>'$data["province_name"].$data["city_name"].$data["county_name"].$data["base_name"]'
),
array(                       //具体设置每列的header
		'type'=>'html',
		'header'=>'组别',
		'name'=>'GROUPNAME_V',
		'value' =>'CHtml::link($data["GROUPNAME_V"], 
			 array(Yii::app()->controller->route.substr(Yii::app()->request->url, strpos(Yii::app()->request->url, "&"),
				strpos(Yii::app()->request->url, "&record_id") == 0 ? strlen(Yii::app()->request->url) : strpos(Yii::app()->request->url, "&record_id") 
			 - strpos(Yii::app()->request->url, "&")  ), "record_id"=>$data["record_id"],))',


/*
 'CHtml::link($data["GROUPNAME_V"], array("btBatterys/details", "status"=>1,
					"redirect"=>1,
					"select_unit"=>Yii::app()->controller->select_unit,
					"select_maker"=>Yii::app()->controller->select_maker,
					"select_size"=>Yii::app()->controller->select_size,
					"select_timer"=>Yii::app()->controller->select_timer,
					"record_id"=>$data["record_id"],
				 
					))',//显示URL
	*/		 
),
/*array(                       //具体设置每列的header
		'name'=>'序列号',
		'value'=>'$data["bt_id"]',
), */
array(                       //具体设置每列的header
		'header'=>'制造商',
		'name'=>'MANNAME_V',
		'value'=>'$data["MANNAME_V"]',
),
/*array(                       //具体设置每列的header
'header'=>'电池类型',
		'name'=>'SORTNAME_V',
		'value'=>'$data["SORTNAME_V"]',
), */
array(
		'header'=> '电池规格',
		'name' => 'BATTERYTYPE_V',
		'value' => '$data["BATTERYTYPE_V"]',
),
/*
array(
		'header'=> '站点类型',
		'name' => 'BASE_TYPE',
		'value' => '$data["BASE_TYPE"]',
),*/
array(                       //具体设置每列的header
		'header'=>'安装日期',
		'name'=>'bt_date',
		'value'=>'$data["bt_date"]',
),
/*
array(                       //具体设置每列的header
		'name'=>'安装日期',
		'value'=>'$data["SETUP_D"]',
),*/
array(                       //具体设置每列的header
		'name'=>'状态',
		'value'=>'$data["STATUS_N"] == 0 ? "绿色" : ($data["STATUS_N"] == 1 ? "黄色" : "红色") ',
),
),
    'template'=>'{items}{summary}{pager}',
    'cssFile' => Yii::app()->request->baseUrl.'/css/widgets/cgridview.css'
)); ?>
</section>



 <section class="grid_9 ui-tabs ui-widget ui-widget-content ui-corner-all" id="dashtabs">
<div class="box-header">
  <?php echo "电池列表"; ?></div> 
<?php $this->widget('zii.widgets.grid.CGridView', array(
	'id'=>'bt-battery-grid1',

	'dataProvider'=>new CArrayDataProvider($battery, array('keyField'=>'RECORD_ID')),
	//'fieldid'=>'RECORD_ID',
	//'filter'=>$model,

	'columns'=>array(

array(
		'name' => '流水号',
		'value' => '$row + 1',
),

array(
		'name' => '电池组名称',
		'value' => '$data->batterys->GROUPNAME_V',
),


array(
		'name' => '电池类型',
		'value' => '$data->dictsort->SORTNAME_V',
),
			 
array(
		'name' => '制造商',
		'value' => '$data->dictmanu->MANNAME_V',
),  
array(
		'name' => '电池规格',
		'value' => '$data->dictbattery->BATTERYTYPE_V',
),  
array(
		'name' => '电池状态',
	//'value' => '$data',
		'type' => 'raw',
		'value' => '$data["STATUS_N"] == 0 ? "<img src=\"'.Yii::app()->baseUrl.'/images/green.png\"/>" : ($data["STATUS_N"] == 1 ? "<img src=\"'.Yii::app()->baseUrl.'/images/yellow.gif\"/>" : "<img src=\"'.Yii::app()->baseUrl.'/images/red.gif\"/>") ',
),
array(
		'name' => '当前电压(V)',
		//'value' => '$data',
		'value'=> 'number_format($data["CURVAL_N"] ,2)',
),
array(
		'name' => '当前内阻(mΩ)',
		//'value' => '$data',
		'value'=>'number_format($data["CURINNER_N"],3)',
),
array(
		'name' => '预估容量(Ah)',
		//'value' => '$data',
		'value'=>'number_format($data["FORCASTVOLUME_N"],2) ',
),
/*array(
		'name' => '汇流排内阻(mΩ)',
		//'value' => '$data',
		'value'=>'number_format($data["CUR_HL_INNER_N"],3) ',
),*/

array(
		'name' => '采集时间',
		//'value' => '$data',
		'value'=>'$data["CURDATE_D"]',
),

		array(
			'class'=>'CButtonColumn',
			'header' => '操作',
//			'template'=>'{view}{update}{delete}{history}',
			'template'=>'{view}{delete}{history}',
		'buttons'=>array
		(
			'view' => array
			(

					'label'=>'详情',
					'imageUrl'=>Yii::app()->request->baseUrl.'/css/img/icons/16/page.png',
					//'url'=>'Yii::app()->createUrl("users/email", array("id"=>$data->RECORD_ID))',
			),
			'update' => array
			(
					'label'=>'修改',
					'imageUrl'=>Yii::app()->request->baseUrl.'/css/img/icons/16/page_edit.png',
					//'url'=>'Yii::app()->createUrl("users/email", array("id"=>$data->RECORD_ID))',
			),
			'delete' => array
			(
					'label'=>'删除',
					//'url'=>'"#"',
					'imageUrl'=>Yii::app()->request->baseUrl.'/css/img/icons/16/page_delete.png',
					//'click'=>'function(){alert("Going down!");}',
			),
			'history' => array
			(
					'label'=>'历史',
					'imageUrl'=>Yii::app()->request->baseUrl.'/images/history.png',
					'url'=>'Yii::app()->createUrl("btBattery/history", array("gid"=>$data->GROUP_V, "sid"=>$data->SERIAL_N))',
					//'visible'=>'true',
					//'click'=>'function(){alert("Going down!");}',
			),
		),
	),
),
    'template'=>'{items}{summary}{pager}',
    'htmlOptions'=>array(
    	'class'=>'cgridview'
    ),
    'cssFile' => Yii::app()->request->baseUrl.'/css/widgets/cgridview.css',
)); ?>
</section>